///sdse_action PhysicsServer

///sdse_lin_includeDir libs/linux/bullet/inc
///sdse_lin_libDir libs/linux/bullet/lib

///sdse_lib bulletdynamics
///sdse_lib bulletcollision
///sdse_lib bulletmath

#ifndef PHYSICSSERVER_H
#define PHYSICSSERVER_H

#include "btBulletDynamicsCommon.h"
#include "system/action.h"

using namespace sde;

class PhysicsServer : public Action {
private:
    btAxisSweep3* broadphase;
    btDefaultCollisionConfiguration* collisionConfiguration;
    btCollisionDispatcher* dispatcher;
    btSequentialImpulseConstraintSolver* solver;
    btDiscreteDynamicsWorld* dynamicsWorld;
    
    float startTime, lastTime;
    int frameCount;

public:
    PhysicsServer(std::string _type, std::string _name, Object* _object);
    ~PhysicsServer();
    
    btDiscreteDynamicsWorld* getDynamicsWorld() {return dynamicsWorld;}
    
    void update(VarMap args);
    void stop();
    
    static btVector3 VectorToBulletVector(Vector3 v);
    static Vector3 BulletVectorToVector(btVector3 v);
    static btQuaternion QuaternionToBulletQuaternion(Quaternion q);
    static Quaternion BulletQuaternionToQuaternion(btQuaternion q);
};

#endif
